package ac.svn.accesscontrol.ui.window;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

import ac.svn.accesscontrol.ui.WhiteLabel;
import ac.svn.accesscontrol.utils.UIUtility;

public class LocationEditorWindow extends JDialog 
{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private JMenuItem addLocationMI;
    private JMenuItem deleteLocationMI;
    private JMenuItem editLocationMI;
    private JMenuItem closeMI;
    private JTextField locationNameTxt;
    public LocationEditorWindow() 
    {
	super();
	setTitle("Location Editor");
	
	Color WHITE = Color.WHITE;
	Border border = UIUtility.setAllShadowedBorder(null);
	
	getContentPane().setLayout(new BorderLayout(0, 0));

	JPanel basePanel = new JPanel();
	basePanel.setBackground(WHITE);
	basePanel.setBorder(border);
	basePanel.setLayout(new BorderLayout(0, 0));
	
	getContentPane().add(basePanel, BorderLayout.CENTER);
	
	JPanel titlePanel = new JPanel();
	titlePanel.setBackground(WHITE);
	titlePanel.setBorder(new TitledBorder(border, "Location Details", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	titlePanel.setLayout(new BorderLayout(0, 0));
	
	basePanel.add(titlePanel, BorderLayout.NORTH);
	
	WhiteLabel lblNewLabel = new WhiteLabel("<HTML>\r\n<H4>Wecome to Locaiton editor.</H4>\r\n</HTML>");
	lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
	titlePanel.add(lblNewLabel);

	JPanel itemDetailsPanel = new JPanel();
	itemDetailsPanel.setBorder(border);
	itemDetailsPanel.setPreferredSize(new Dimension(10, 100));
	itemDetailsPanel.setLayout(new BorderLayout(9, 1));
	
	titlePanel.add(itemDetailsPanel, BorderLayout.SOUTH);
	

	JPanel pathPanel = new JPanel();
	pathPanel.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
	itemDetailsPanel.add(pathPanel, BorderLayout.NORTH);
	pathPanel.setLayout(new BorderLayout(10, 0));

	JLabel lblLocationName = new JLabel("  Location Name");
	pathPanel.add(lblLocationName, BorderLayout.WEST);

	locationNameTxt = new JTextField();
	pathPanel.add(locationNameTxt, BorderLayout.CENTER);
	locationNameTxt.setColumns(10);

	JPanel bodyPanel = new JPanel();
	bodyPanel.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
	itemDetailsPanel.add(bodyPanel, BorderLayout.CENTER);
	bodyPanel.setLayout(new BorderLayout(10, 0));

	JLabel lblItemName = new JLabel("  Location Path  ");
	bodyPanel.add(lblItemName, BorderLayout.WEST);

	JScrollPane scrollPane = new JScrollPane();
	bodyPanel.add(scrollPane, BorderLayout.CENTER);

	JTextPane textPane = new JTextPane();
	scrollPane.setViewportView(textPane);

	JMenuBar menuBar = new JMenuBar();
	setJMenuBar(menuBar);

	JMenu actionMenu = new JMenu("Action");
	actionMenu.setMnemonic('A');
	menuBar.add(actionMenu);

	addLocationMI = new JMenuItem("Add Location..");
	addLocationMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));
	addLocationMI.setMnemonic('A');
	actionMenu.add(addLocationMI);

	editLocationMI = new JMenuItem("Edit Location..");
	editLocationMI.setMnemonic('E');
	editLocationMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK));
	actionMenu.add(editLocationMI);

	deleteLocationMI = new JMenuItem("Delete Location..");
	deleteLocationMI.setMnemonic('D');
	deleteLocationMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK));
	actionMenu.add(deleteLocationMI);

	closeMI = new JMenuItem("Close");
	closeMI.setMnemonic('C');
	closeMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK));
	actionMenu.add(closeMI);
    }

    public static void main(String[] args)
    {
	(new LocationEditorWindow()).setVisible(true);
    }

}
